from django.contrib.auth.models import Group, User
from django.shortcuts import render
from rest_framework import permissions, status, viewsets
from rest_framework.decorators import api_view
from rest_framework.response import Response

from .serializers import *


class GroupViewSet(viewsets.ModelViewSet):
    queryset = Group.objects.all()
    serializer_class = GroupSerializer
    permission_classes = [permissions.IsAuthenticated]


class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all().order_by('-date_joined')
    serializer_class = UserSerializer
    permission_classes = [permissions.IsAuthenticated]


@api_view(["GET"])
def Test01(request):
    # qs_all = SonarProfile.objects.all()
    # qs = qs_all
    if request.method == "GET":
        # data = [
        #     [0.0, 35.5, 685.4230769230769, 0.0],
        #     [0.0, 65.035140562249, 904.2050193050193, 0.0],
        #     [0.0, 95.08448117539028, 1056.6454281083143, 0.0],
        #     [0.0, 124.5, 1130.7777777777778, 0.0],
        #     [0.0, 155.76104417670683, 1189.014219114219, 0.0],
        #     [0.0, 187.55324055368803, 1235.47850877193, 0.0],
        #     [0.0, 220.5, 1272.310344827586, 0.0],
        #     [0.0, 254.46317829457362, 1300.1223700093635, 0.0],
        #     [0.0, 287.4659332236993, 1319.476505528111, 0.0],
        #     [0.0, 322.828, 1332.1066251185475, 0.0],
        #     [0.0, 359.26452905811624, 1351.9855834464045, 0.0],
        #     [0.0, 397.1508749108683, 1364.7311579462355, 0.0],
        #     [0.0, 435.6788895111277, 1371.2481405383194, 0.0],
        #     [0.0, 474.76430375827687, 1382.1512404580153, 0.0]
        # ]
        data = [[
            0.0,
            35.5,
        ], [685.4230769230769, 0.0], '-', [
            0.0,
            65.035140562249,
        ], [904.2050193050193, 0.0], '-', [
            0.0,
            95.08448117539028,
        ], [1056.6454281083143, 0.0], '-', [
            0.0,
            124.5,
        ], [1130.7777777777778, 0.0], '-', [
            0.0,
            155.76104417670683,
        ], [1189.014219114219, 0.0], '-', [
            0.0,
            187.55324055368803,
        ], [1235.47850877193, 0.0], '-', [
            0.0,
            220.5,
        ], [1272.310344827586, 0.0], '-', [
            0.0,
            254.46317829457362,
        ], [1300.1223700093635, 0.0], '-', [
            0.0,
            287.4659332236993,
        ], [1319.476505528111, 0.0], '-', [
            0.0,
            322.828,
        ], [1332.1066251185475, 0.0], '-', [
            0.0,
            359.26452905811624,
        ], [1351.9855834464045, 0.0], '-', [
            0.0,
            397.1508749108683,
        ], [1364.7311579462355, 0.0], '-', [
            0.0,
            435.6788895111277,
        ], [1371.2481405383194, 0.0], '-', [
            0.0,
            474.76430375827687,
        ], [1382.1512404580153, 0.0]]
        return Response(data, status.HTTP_200_OK)
